package com.kuangjia.conferenceroomrental.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import javax.validation.constraints.Future;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 预约实体类
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("reservations")
public class Reservation implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 会议室ID
     */
    @NotNull(message = "会议室ID不能为空")
    @TableField("room_id")
    private Long roomId;
    
    /**
     * 会议室信息（非数据库字段）
     */
    @TableField(exist = false)
    private Room room;
    
    /**
     * 会议室名称（非数据库字段，用于SQL JOIN查询）
     */
    @TableField(exist = false)
    private String roomName;
    
    /**
     * 用户ID
     */
    @NotNull(message = "用户ID不能为空")
    @TableField("user_id")
    private Long userId;
    
    /**
     * 用户信息（非数据库字段）
     */
    @TableField(exist = false)
    private User user;
    
    /**
     * 开始时间
     */
    @NotNull(message = "开始时间不能为空")
    @TableField("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
    private LocalDateTime startTime;
    
    /**
     * 结束时间
     */
    @NotNull(message = "结束时间不能为空")
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
    private LocalDateTime endTime;
    
    /**
     * 用途
     */
    @TableField("purpose")
    private String purpose;
    
    /**
     * 参会人数
     */
    @Positive(message = "参会人数必须大于0")
    @TableField("attendees")
    private Integer attendees;
    
    /**
     * 状态
     */
    @NotBlank(message = "状态不能为空")
    @TableField("status")
    private String status; // PENDING, APPROVED, REJECTED, CANCELLED
    
    /**
     * 创建时间
     */
    @TableField("created_at")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    @TableField("updated_at")
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
    private LocalDateTime updatedAt;
} 